//
//  UIImage+Render.m
//  BuDeJie
//
//  Created by sunny on 16/3/31.
//  Copyright © 2016年 sunny. All rights reserved.
//

#import "UIImage+Render.h"

@implementation UIImage (Render)
//返回一张没有被渲染的图片
+ (UIImage *)imageNameOriginal:(NSString *)imageName
{
    UIImage *image = [UIImage imageNamed:imageName];
    return [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{
    CGRect rect = CGRectMake(0, 0, size.width, size.height);
//    开启图形上下文
    UIGraphicsBeginImageContext(size);
//    得到图形上下文
    CGContextRef context = UIGraphicsGetCurrentContext();
//    填充满上下文
    CGContextSetFillColorWithColor(context,color.CGColor);
    CGContextFillRect(context, rect);
//    从上下文获取图片
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
//    关闭上下文
    UIGraphicsEndImageContext();
//    返回图片
    return img;
}
@end
